{% extends 'base_for_react.html' %}
{% load seahub_tags avatar_tags i18n %}
{% load render_bundle from webpack_loader %}

{% block sub_title %}{% trans "Settings" %} - {% endblock %}

{% block extra_style %}
{% render_bundle 'settings' 'css' %}
{% endblock %}

{% block extra_script %}
<script type="text/javascript">
// overwrite the one in base_for_react.html
window.app.pageOptions = {
  avatarURL: '{% avatar_url request.user 160 %}',
  csrfToken: '{{ csrf_token }}',

  enableUpdateUserInfo: {% if ENABLE_UPDATE_USER_INFO %} true {% else %} false {% endif %},
  nameLabel: "{% trans "Name:" context "true name" %}",
  enableUserSetContactEmail: {% if ENABLE_USER_SET_CONTACT_EMAIL %} true {% else %} false {% endif %},
  
  canUpdatePassword: {% if not is_ldap_user and ENABLE_CHANGE_PASSWORD %} true {% else %} false {% endif %},
  {% if not is_ldap_user and ENABLE_CHANGE_PASSWORD %}
  passwordOperationText: {% if user_unusable_password %}"{% trans "Set Password" %}"{% else %}"{% trans "Update" %}"{% endif %},
  {% endif %}

  enableWebdavSecret: {% if ENABLE_WEBDAV_SECRET %} true {% else %} false {% endif %},
  {% if ENABLE_WEBDAV_SECRET %}
  webdavPasswd: '{{ webdav_passwd|escapejs }}',
  {% endif %}

  enableAddressBook: {% if ENABLE_ADDRESSBOOK_OPT_IN %} true {% else %} false {% endif %},

  currentLang: {
    langCode: '{{ LANGUAGE_CODE|escapejs }}',
    langName: '{{ LANGUAGE_CODE|language_name_local|capfirst|escapejs }}'
  },
  langList: (function() {
    var list = [];
    {% for LANG in LANGUAGES %}
    list.push({
      langCode: '{{LANG.0|escapejs}}',
      langName: '{{LANG.1|escapejs}}'
    });
    {% endfor %}
    return list;
  })(),

  {% if is_pro %}
  initialEmailNotificationInterval: {{ email_notification_interval }},
  {% endif %}

  twoFactorAuthEnabled: {% if two_factor_auth_enabled %} true {% else %} false {% endif %},
  {% if two_factor_auth_enabled %}
  defaultDevice: {% if default_device %} true {% else %} false {% endif %},
  backupTokens: {{backup_tokens}},
  {% endif %}

  enableWechatWork: {% if enable_wechat_work %} true {% else %} false {% endif %},
  langCode: "{{LANGUAGE_CODE|escapejs}}",
  {% if enable_wechat_work %}
  socialConnected: {% if social_connected %} true {% else %} false {% endif %},
  socialNextPage: "{{ social_next_page|escapejs }}",
  {% endif %}

  enableDingtalk: {% if enable_dingtalk %} true {% else %} false {% endif %},
  {% if enable_dingtalk %}
  socialConnectedDingtalk: {% if social_connected_dingtalk %} true {% else %} false {% endif %},
  socialNextPage: "{{ social_next_page|escapejs }}",
  {% endif %}

  enableDeleteAccount: {% if ENABLE_DELETE_ACCOUNT %} true {% else %} false {% endif %}
};
</script>
{% render_bundle 'settings' 'js' %}
{% endblock %}
